package lry.raft;

import com.lry.message.Message;
import com.lry.producer.DefaultMqProducer;
import com.lry.producer.SendResult;

import java.nio.charset.StandardCharsets;

public class BasicProducer {

    public static void main(String[] args) throws InterruptedException {

        //地址可以不用主节点，raft会自动转发到master
        DefaultMqProducer producer = new DefaultMqProducer("localhost:2181",true);
        producer.start();

        for(int i=1;i<2;i++){
            Message message = new Message();
            message.setBody(("hello world"+i).getBytes(StandardCharsets.UTF_8));
            message.setTopic("topic");
            SendResult result = producer.send(message);
            System.out.println(result);

            Thread.sleep(1000);
        }
    }
}
